#include "scip/scip.h"
#include "scip/scipdefplugins.h"

#include "time.h"

#define SCIP_DEBUG 1

int main(int argc, char ** argv) {
	unsigned int seed = time(NULL );
	SCIP* scip = NULL;
	SCIP_VAR ** array = NULL;
	SCIP_VAR* i1 = NULL;
	SCIP_VAR* i2 = NULL;
	SCIP_CONS * cons = NULL;
	long long int weights[2];
	long long int sumOfWeights = 0;

	SCIP_CALL( SCIPcreate(&scip));
	assert(scip);
	SCIP_CALL( SCIPcreateProbBasic(scip, "KP"));
	SCIP_CALL( SCIPincludeDefaultPlugins(scip));

	SCIP_CALL(
			SCIPcreateVarBasic(scip, &i1, "item_1", 0,1, SCIPgetRandomInt(1,10,&seed), SCIP_VARTYPE_BINARY));
	assert(i1);
	SCIP_CALL(
			SCIPcreateVarBasic(scip, &i2, "item_2", 0,1, SCIPgetRandomInt(1,10,&seed), SCIP_VARTYPE_BINARY));
	assert(i2);

	SCIP_CALL( SCIPaddVar(scip, i1));
	SCIP_CALL( SCIPaddVar(scip, i2));

	array = (SCIP_VAR **) malloc(2 * sizeof(SCIP_VAR *));
	array[0]=i1;
	array[1]=i2;

	weights[0] = SCIPgetRandomInt(1, 10, &seed);
	weights[1] = SCIPgetRandomInt(1, 10, &seed);
	sumOfWeights = weights[0] + weights[1];

	SCIP_CALL(
			SCIPcreateConsBasicKnapsack(scip,&cons,"knapsack",2,array,weights,sumOfWeights-1));

	SCIP_CALL(SCIPaddCons(scip,cons));

	SCIP_CALL(SCIPsetObjsense(scip, SCIP_OBJSENSE_MAXIMIZE));

	SCIP_CALL(SCIPsolve(scip));

	SCIP_CALL(SCIPfree(&scip));

	free(array);
	return 0;
}
